import rxAjax from '@/assets/js/ajax.js';
import FormUtil from "@/assets/js/FormUtil";

//业务代码生成表 api接口
export const FormCodegenBusinessApi = {};

FormCodegenBusinessApi.baseUrl= '/api-form/form/codegen/formCodegenBusiness';
FormCodegenBusinessApi.exportUrl= FormCodegenBusinessApi.baseUrl + '/listExport';

//查询列表
FormCodegenBusinessApi.query=function (parameter) {
  var url= FormCodegenBusinessApi.baseUrl + '/query';
  return rxAjax.postJson(url,parameter).then (res => {
    return res.result
  })
}

/**
* 获取单记录
* @param pkId
* @returns {*}
*/
FormCodegenBusinessApi.get =function(pkId) {
  var url= FormCodegenBusinessApi.baseUrl + '/get?pkId=' + pkId;
  return rxAjax.get(url);
}

//保存数据
FormCodegenBusinessApi.save =function(parameter) {
  var url= FormCodegenBusinessApi.baseUrl + '/save';
  return rxAjax.postJson(url,parameter);
}

//删除数据
FormCodegenBusinessApi.del =function(parameter) {
  var url= FormCodegenBusinessApi.baseUrl + '/del';
  return rxAjax.postUrl(url,parameter);
}

FormCodegenBusinessApi.reloadColumns=function(parameter){
  var url= FormCodegenBusinessApi.baseUrl + '/reloadColumns';
  return rxAjax.postJson(url,parameter);
}

FormCodegenBusinessApi.genCode=function(pkId){
    var url = FormCodegenBusinessApi.baseUrl + '/genCode';
    return FormUtil.doExport(url,{pkId:pkId});
}
//变更分类
FormCodegenBusinessApi.changeCategory=function(ids,categoryId){
    var url= FormCodegenBusinessApi.baseUrl+'/changeCategory';
    return rxAjax.postForm(url, {ids:ids,categoryId:categoryId});
}

export  default FormCodegenBusinessApi;

